package thread;

import java.math.BigInteger;

/**
 * 优先级测试，结果显示低优先级和高优先级的执行次数基本相同
 */
public class PriorityTest {
	
	public static BigInteger count1 = new BigInteger("0");
	public static BigInteger count2 = new BigInteger("0");

	public static void main(String[] args) {
		
		Thread t1 = new Thread(){
			
			@Override
			public void run() {
				
				while(true){
					
					count1 = count1.add(new BigInteger("1"));
//					System.out.println("count1 : " + count1 + ", count2 : " + count2);
				}
			}
		};
		
		Thread t2 = new Thread(){
			
			@Override
			public void run() {
				
				while(true){
					
					count2 = count2.add(new BigInteger("1"));
//					System.out.println("count1 : " + count1 + ", count2 : " + count2);
				}
			}
		};
		
		
		t1.setPriority(Thread.MIN_PRIORITY);
		t2.setPriority(Thread.MAX_PRIORITY);
		t1.start();
		t2.start();
	}
}
